package com.soft.base.contract;


/**
 * class
 *
 * @author user
 * @date 2020/06/05
 */
public interface CacheFacade {

    interface RememberCallback<T> {
        /**
         * get
         * @return
         */
        T get();
    }

    /**
     * forget
     * @param key
     */
    void forget(String key);

    /**
     * exists
     * @param key
     * @return
     */
    boolean exists(String key);

    /**
     * getObject
     * @param key
     * @param cls
     * @param <T>
     * @return
     */
    <T> T getObject(String key, Class<T> cls);

    /**
     * setObject
     * @param key
     * @param data
     * @param <T>
     */
    <T> void setObject(String key, T data);

    /**
     * setObject
     * @param key
     * @param data
     * @param expire
     * @param <T>
     */
    <T> void setObject(String key, T data, long expire);

    /**
     * remember
     * @param key
     * @param seconds
     * @param callback
     * @param <T>
     * @return
     */
    <T> T remember(String key, long seconds, final RememberCallback<T> callback);
}
